package com.rongc.client.freight.business.mine.view.activity;


import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.rongc.client.core.utils.StringUtils;
import com.rongc.client.freight.ApiUrl;
import com.rongc.client.freight.R;
import com.rongc.client.freight.UniApplication;
import com.rongc.client.freight.base.BaseActivity;
import com.rongc.client.freight.base.view.widget.ProgressWebView;

import butterknife.Bind;

public class ShopActivity extends BaseActivity {
	@Bind(R.id.webview)
	ProgressWebView webview;
	String url;

	protected void initTitleBar(){}

	@Override
	public int getLayoutId() {
		return R.layout.activity_active_shop;
	}

	@Override
	public void initParams() {
		url = getIntent().getStringExtra("data");
	}

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE|WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

//		getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
		webview.getSettings().setJavaScriptEnabled(true);
		webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
		webview.getSettings().setSupportMultipleWindows(true);
//		webview.setWebViewClient(new WebViewClient());
		webview.setWebChromeClient(new WebChromeClient());
		webview.setWebViewClient(new WebViewClient(){

			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				if(url.contains("backClick")){
					finish();
					return true;
				}
				return false;
			}

		});
		if(StringUtils.isNotEmpty(url)){
			webview.loadUrl(url);
		}else{
			url = ApiUrl.getDefaultHost()+"shop.html?userid="+ UniApplication.getInstance().getUserInfo().getUserId();
			webview.loadUrl(url);
		}
	}
}
